package com.adou.d16.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * 目标：使用字节输入流一次读取所有字节
 */
public class ITest3 {
    public static void main(String[] args) throws Exception {
        // 1.一次性读取完
        InputStream is = new FileInputStream("d1-helloword-app\\src\\it03.txt");

//        // 2.准备一个字节数组，大小与文件一样
//        File file = new File("d1-helloword-app\\src\\it03.txt");
//        long size = file.length();
//        byte[] buffer = new byte[(int) size];
//
//        // 读取
//        int len = is.read(buffer);
//        System.out.println(new String(buffer));
//
//        System.out.println(size);
//        System.out.println(len);


        byte[] buffer = is.readAllBytes();
        System.out.println(new String(buffer));

    }
}
